<template>
	<cl-select-table
		v-model="value"
		:title="t('选择帖子管理')"
		:service="service.community.post"
		:columns="columns"
		:multiple="multiple"
		:dict="{ img: 'images', text: 'nickname' }"
		pickerType="default"
	/>
</template>

<script setup lang="ts">
defineOptions({
	name: "community-post-select",
});

import { useCool } from "/@/cool";
import { useI18n } from "vue-i18n";
import { CrudProps } from "/#/crud";
import { reactive, ref, useModel } from "vue";

const props = defineProps({
	...CrudProps,
	modelValue: null,
	multiple: Boolean,
});

const { service } = useCool();
const { t } = useI18n();

const value = useModel(props, "modelValue");

// 选项
const options = reactive({
	status: [
		{ label: t("正常"), value: 0 },
		{ label: t("删除"), value: 1 },
		{ label: t("屏蔽"), value: 2 },
	],
});

const columns = ref([
	{
		label: t("头像"),
		prop: "avatarUrl",
		minWidth: 100,
		component: { name: "cl-image", props: { size: 60 } },
	},
	{
		label: t("内容"),
		prop: "content",
		showOverflowTooltip: true,
		minWidth: 200,
	},
	{
		label: t("图片"),
		prop: "images",
		minWidth: 100,
		component: { name: "cl-image", props: { size: 60 } },
	},
	{ label: t("发布人昵称"), prop: "nickName", minWidth: 140 },
	{
		label: t("发布时间"),
		prop: "publishTime",
		minWidth: 170,
		sortable: "custom",
		component: { name: "cl-date-text" },
	},
	{
		label: t("浏览次数"),
		prop: "viewCount",
		minWidth: 140,
		sortable: "custom",
	},
	{
		label: t("点赞数"),
		prop: "likeCount",
		minWidth: 140,
		sortable: "custom",
	},
	{
		label: t("评论数"),
		prop: "commentCount",
		minWidth: 140,
		sortable: "custom",
	},
	{ label: t("状态"), prop: "status", minWidth: 120, dict: options.status },
]);
</script>
